package com.mspbots.api.service.impl;

import com.fasterxml.jackson.databind.JsonNode;
import com.mspbots.api.service.SystemConfigurationService;
import com.mspbots.cw.request.SystemConfigurationDTO;
import com.mspbots.dto.enums.Configuration;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

import java.time.Duration;

import static java.time.temporal.ChronoUnit.SECONDS;

/**
 * com.mspbots.api.service.impl.SystemConfigurationServiceImpl
 *
 * @author Jun Zhou
 * @date 10:09 2019/7/1
 **/
@Deprecated
@Service
public class SystemConfigurationServiceImpl extends BaseGenericService implements SystemConfigurationService {

    @Override
    public SystemConfigurationDTO findByKeyword(Configuration keyword) {
        Mono<JsonNode> resultMono = this.apiClient.get("/system-configuration/keyword/" + keyword.getKeyword());
        JsonNode result = resultMono.block(Duration.of(5, SECONDS));
        return this.objectMapper.convertValue(result, SystemConfigurationDTO.class);
    }
}
